home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / termv4.6 / extras / source / gtlayout-source.lha / LTP_HandleHistory.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-18  |  1.8 KB  |  99 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. VOID
  15. LTP_HandleHistory(struct SGWork *Work)
  16. {
  17.     ObjectNode *Node;
  18.  
  19.     if(GETOBJECT(Work->Gadget,Node))
  20.     {
  21.         if(Node->Special.String.HistoryHook)
  22.         {
  23.             struct Node    *Choice = NULL;
  24.             struct MinList    *List    = Node->Special.String.HistoryHook->h_Data;
  25.  
  26.             if(Work->IEvent->ie_Qualifier & QUALIFIER_SHIFT)
  27.             {
  28.                 if(Work->IEvent->ie_Code == CURSORUP)
  29.                 {
  30.                     if(List->mlh_Head->mln_Succ)
  31.                         Choice = (struct Node *)List->mlh_Head;
  32.                 }
  33.                 else
  34.                 {
  35.                     if(List->mlh_Head->mln_Succ)
  36.                         Choice = (struct Node *)List->mlh_TailPred;
  37.                 }
  38.             }
  39.             else
  40.             {
  41.                 struct Node *Current = Node->Special.String.CurrentNode;
  42.  
  43.                 if(Work->IEvent->ie_Code == CURSORUP)
  44.                 {
  45.                     if(Current)
  46.                     {
  47.                         if(Current->ln_Pred->ln_Pred)
  48.                             Choice = Current->ln_Pred;
  49.                         else
  50.                             Choice = Current;
  51.                     }
  52.                     else
  53.                     {
  54.                         if(List->mlh_Head->mln_Succ)
  55.                             Choice = (struct Node *)List->mlh_TailPred;
  56.                     }
  57.                 }
  58.                 else
  59.                 {
  60.                     if(Current)
  61.                     {
  62.                         if(Current->ln_Succ->ln_Succ)
  63.                             Choice = Current->ln_Succ;
  64.                     }
  65.                 }
  66.             }
  67.  
  68.             if(Choice != Node->Special.String.CurrentNode)
  69.             {
  70.                 if(Choice)
  71.                 {
  72.                     strcpy(Work->WorkBuffer,Choice->ln_Name);
  73.  
  74.                     Work->NumChars = Work->BufferPos = strlen(Work->WorkBuffer);
  75.                 }
  76.                 else
  77.                 {
  78.                     Work->WorkBuffer[0]    = 0;
  79.                     Work->NumChars    = 0;
  80.                     Work->BufferPos    = 0;
  81.                 }
  82.  
  83.                 if(Node->Type == INTEGER_KIND)
  84.                 {
  85. #ifdef DO_HEXHOOK
  86.                     LTP_ConvertNum((Node->Min < 0),Work->WorkBuffer,&Work->LongInt);
  87. #else
  88.                     Work->LongInt = LTP_Atol(Work->WorkBuffer);
  89. #endif
  90.                 }
  91.  
  92.                 Node->Special.String.CurrentNode = Choice;
  93.  
  94.                 Work->Actions = (Work->Actions & ~SGA_BEEP) | SGA_USE | SGA_REDISPLAY;
  95.             }
  96.         }
  97.     }
  98. }
  99.